import datastructure.linklist.ListNode;

/**
 * @Author ZhangCuirong
 * @Date 2025/8/28 14:30
 * @description:
 */
public class LCR140 {
    public ListNode trainingPlan(ListNode head, int cnt) {
        ListNode fast = head;
        ListNode slow = head;
        while (cnt-- != 0) {
            fast = fast.next;
        }
        while (fast!= null) {
            fast = fast.next;
            slow = slow.next;
        }
        return slow;
    }

    public static void main(String[] args) {
        LCR140 solution = new LCR140();
        ListNode head = ListNode.arrayToList(new int[]{2, 4, 7, 8});
        ListNode res = solution.trainingPlan(head, 1);
        System.out.println(res.val);
    }
}
